package com.piesat.quake.common.mqtt.decoder;

import com.piesat.quake.common.mqtt.decoder.common.CommonDecoder;
import com.piesat.quake.common.mqtt.decoder.entity.TiData;

public class TiDataDecoder extends CommonDecoder<TiData> {
    public TiDataDecoder(byte[] bytes) {
        super(bytes);
    }

    @Override
    public TiData decoder() {
        TiData data = new TiData();
        data.setType(this.readString(2));
        data.setLength(this.readIntegerLE());
        data.setId(this.readString(8));
        data.setTimestamp(this.readDoubleLE());
        data.setTriggerNum(this.readIntegerLE());
        data.setTriggerTime(this.readDoubleLE());
        data.setIntensity(this.readByte());
        data.setAmp(this.readFloatLE());
        data.setKey(data.getId() + "_" + data.getTimestamp().longValue());
        return data;
    }
}
